<template>
    <div class="wrap">
        <van-notice-bar v-if="globalRole==0" text="请完善个人信息" left-icon="volume-o" />
       
        <!-- <van-notice-bar v-if="globalRole!=0" scrollable color="#1989fa" background="#ecf9ff" left-icon="info-o">
           当前相机权限：{{messaget}}
        </van-notice-bar> -->
        <div class="content-wrap">
            <van-row class="gridtitle">
                <van-grid :column-num="3">
                   
                    <van-grid-item style="width:100%" @click="nextpage('myinfo')">
                        <img style="width:30%" src="../assets/images/jiaojieban.png" />
                        <div class="nav-desc">我的管理</div>
                    </van-grid-item>
                    <van-grid-item v-if="isCheck==1" style="width:100%" @click="nextpage('myvillage')">
                        <img style="width:30%" src="../assets/images/jinhuo.png" />
                        <div class="nav-desc">小区管理</div>
                    </van-grid-item>
                    <van-grid-item v-if="(globalRole==1||globalRole==3)&&isCheck==1" style="width:100%" @click="nextpage('myfriends')">
                        <img style="width:30%" src="../assets/images/shenhe.png" />
                        <div class="nav-desc">好友管理</div>
                    </van-grid-item>
                     <van-grid-item v-if="globalRole==1&&isCheck==1" style="width:100%" @click="nextpage('check')">
                        <img style="width:30%" src="../assets/images/jiancha.png" />
                        <div class="nav-desc">访客审核</div>
                    </van-grid-item>
                     <van-grid-item v-if="globalRole==1&&isCheck==1" style="width:100%" @click="nextpage('historycheck')">
                        <img style="width:30%" src="../assets/images/pandian.png" />
                        <div class="nav-desc">访客历史</div>
                    </van-grid-item>
                     
                    <van-grid-item  style="width:100%" @click="nextpage('tiandan')">
                        <img style="width:30%" src="../assets/images/shangpinbianji.png" />
                        <div class="nav-desc">访客申请</div>
                    </van-grid-item>
                      <van-grid-item  style="width:100%" @click="nextpage('historytiandan')">
                        <img style="width:30%" src="../assets/images/pandian.png" />
                        <div class="nav-desc">访问历史</div>
                    </van-grid-item>
                    <!-- v-if="(globalRole==1||globalRole==2)&&isCheck==1" -->
                     
                     <van-grid-item style="width:100%" @click="nextpage('permision')">
                        <img style="width:30%" src="../assets/images/shezhi.png" />
                        <div class="nav-desc">权限列表</div>
                    </van-grid-item>
                     <van-grid-item style="width:100%" @click="nextpage('servelist')">
                        <img style="width:30%" src="../assets/images/tuihuo.png" />
                        <div class="nav-desc">维修服务</div>
                    </van-grid-item>
                </van-grid>
            </van-row>  
        </div>
    </div>
</template>

<script>
 import { Notify } from 'vant';
 import api from './api/myinfo.js'
    export default {
        data: function () {
            return {
                isCheck:'',
                messaget:'',
                globalRole:'',
                numpai:'',
                gongli:'',
                sijiwaichu:'',
                sijiwaichu1:'',
                bumenNum:'',
                chuchenum:{},
                zongshengqing:'',
                count:'',
               dataList:[],
               roleCode:roleCode
            }
        },
        components: {
           
        },
        created(){
            this.globalRole=globalRole
            this.getRole()
        },
        mounted(){
           
        },

        methods: {
        getRole(){
            
            let that=this
            api.getRole({openId:openid}).then(e=>{
                
                if(e.code==200){
                   
                    globalRole=e.data.isOwner
                    this.isCheck=e.data.isCheck
                    that.globalRole=globalRole
                    setCookie('globalRole',globalRole,123)
                    
                    
                }
            }).catch(err=>{
                
                    console.log(err.response)
            })


            api.getOn({openId:openid}).then(e=>{
                   
                    if(e.code==200){
                        switch(Number(e.data)){
                            //0-未知 1-不允许 2-允许 3-失败
                            case 0:
                                that.messaget='未知'
                                break;
                            case 1:
                                that.messaget='不允许,请上传清晰照'
                                break;
                            case 2:
                                that.messaget='允许'
                                break;
                            case 3:
                                that.messaget='失败'
                                break;
                        }           
                    }
                }).catch(err=>{
                     
                     console.log(err.response)
                })
        },
          
            getOpenID(){
                let that=this
                let code=getQueryVariable('code')
                api.getOpenID({code}).then(e=>{
                    
                    openid=e.data.openId
                    that.getRole()
                    
                    setCookie('openid',openid,123)
                }).catch(err=>{
                    
                   console.log(err.response.data)
                })
            },
            edit(code){
                this.$router.push({ path: 'changedan',query: { id:code }})
            },
            add(){
                Notify({ type: 'primary', message: `更多功能正在探索` });
            },
            
           logout(){
               this.$router.push('/login')
           },
          
            nextpage(val, type){
              this.$router.push({path:`/${val}` , query: {type}}) 
            }
        }
    }
</script>

<style scoped lang="scss">
@import "./common.scss";
    .desc-num{
        color:#409eff;
    }
    .che-num{
        padding:px2rem(5px);
        font-size:px2rem(9px);
    }
    .nav-desc{
        font-size:px2rem(8px);
        padding-top:px2rem(5px)
    }
    .list-title{
        width:90%;
        margin:0 auto;
        margin-top:px2rem(10px);
        color:#409eff;
        font-size:px2rem(10px);
    }
    .content-wrap{
        margin-top:px2rem(5px);
    }
    .out-wrap{
        margin:0 auto;
        position:fixed;
        bottom:px2rem(40px);
        left:px2rem(30px);
        right:px2rem(30px);
    }

    .view{
        position:absolute;
        right:px2rem(14px);
        font-size:px2rem(10px);
        top:40%;
        color:red;
        padding:px2rem(1px) px2rem(3px);
        border-radius:px2rem(2px)
    }
.search-box{
    height:px2rem(10px);
    background:#fff;
}
.reason{
    font-size:px2rem(12px);
    color:#747474;
}
.item-wrap{
    box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
    
    position:relative;
    background:#fff;
    width:90%;
    margin:0 auto;
    padding:px2rem(10px) px2rem(6px);
    margin-top:px2rem(10px);
}
.wrap{
    min-height:100%;
    background:#f1f0f5;
    height: 100%;
    overflow: auto
}
.time{
    font-size:px2rem(10px);
    color:#797979;
    display:flex;
    align-items: center;
    height:px2rem(16px);
}
.time-inner{
    padding-left:px2rem(4px);
}
.user{
    font-size:px2rem(11px);
    color:#747474;
    margin:px2rem(4px) 0;
}
.hasleader{
    font-size:px2rem(11px);
    color:#747474;
}
.item {
    font-size: 16px;
}
.status{
    position:absolute;
    color:red;
    right:px2rem(14px);
    font-size:px2rem(10px);
}
.gridtitle {
    background-color: #fff;
    margin-top: px2rem(10px);
}

</style>
